package core.lib.tools;

import core.lib.interfaces.LogAgent;

public final class CoreLog
{
	public static final int LEVEL_VERBOSE = 0;
	public static final int LEVEL_INFO = 1;
	public static final int LEVEL_DEBUG = 2;
	public static final int LEVEL_WARNING = 3;
	public static final int LEVEL_ERROR = 4;

	private static LogAgent gLogAgent = null;
	private static int gLogLevel = LEVEL_VERBOSE;

	public final static void setLogAgent(Class<LogAgent> logAgentClass)
	{
		try
		{
			gLogAgent = logAgentClass.newInstance();
		}
		catch (InstantiationException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (IllegalAccessException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public final static void log(int level, String tag, String msg)
	{
		if (gLogAgent != null)
		{
			gLogAgent.addLog(tag, msg);
		}
	}

	public final static void log(int level, String tag, String msg, Throwable tr)
	{
		if (gLogAgent != null)
		{
			gLogAgent.addLog(tag, msg, tr);
		}
	}
}
